package com.brspace.qualitycontrol.utils;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class BaseController {
    /**
     * 操作成功的状态码
     */
    public static final int OK=20000;


    @ExceptionHandler(ServiceException.class)
    public JsonResult<Void> handleException(Throwable e) {
        JsonResult<Void> jr = new JsonResult<>(e);

        if (e instanceof ServiceException) {
            jr.setCode(4000);
        }
        return jr;
    }
}
